<html>
<head><meta charset="utf-8"><title>proc-macro · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html">proc-macro</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="194678895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194678895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194678895">(Apr 20 2020 at 14:02)</a>:</h4>
<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span> <span class="user-mention" data-user-id="133169">@matklad</span> is there a reason we don't use <code>anyhow</code> in <code>ra_proc_macro*</code> crates like we do in <code>ra_project_model</code>?</p>



<a name="194679185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194679185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194679185">(Apr 20 2020 at 14:05)</a>:</h4>
<p>Personally I just prevent to use any external crate as possible when I implement a new feature initially. But I think it is okay to change it to use anyhow.</p>



<a name="194679250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194679250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194679250">(Apr 20 2020 at 14:05)</a>:</h4>
<p>I actually think that anyhow would be a bad fit there</p>



<a name="194679385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194679385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194679385">(Apr 20 2020 at 14:06)</a>:</h4>
<p>The code isn't in cache for me, but I'd expect something like <code>io::Result&lt;Result&lt;tt::TokenTree, ExpansionError&gt;&gt;</code></p>



<a name="194679560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194679560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194679560">(Apr 20 2020 at 14:08)</a>:</h4>
<p>Ie, we have to failure modes, which we need to distinguish between:</p>
<ul>
<li>the external process died (and for that an io::Error is the appropriate type)</li>
<li>macro expansion failed because the input or macro is malformed. For that, we should have a dedicated error type, maybe shared by mbe and proc-macro, maybe unique to proc macro</li>
</ul>



<a name="194679640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194679640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194679640">(Apr 20 2020 at 14:08)</a>:</h4>
<p>Good point</p>



<a name="194679869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194679869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194679869">(Apr 20 2020 at 14:10)</a>:</h4>
<p>By the way, I've just tried proc macros support with <a href="https://docs.rs/soa_derive/0.8.0/soa_derive/" title="https://docs.rs/soa_derive/0.8.0/soa_derive/"><code>soa_derive</code></a> crate and got </p>
<div class="codehilite"><pre><span></span>Fail to find proc macro. Error: Unknown(
    &quot;Empty result&quot;,
)
</pre></div>


<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span> any assumptions?</p>



<a name="194679945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194679945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194679945">(Apr 20 2020 at 14:11)</a>:</h4>
<p>The code:</p>
<div class="codehilite"><pre><span></span><span class="k">use</span><span class="w"> </span><span class="n">soa_derive</span>::<span class="n">StructOfArray</span><span class="p">;</span><span class="w"></span>

<span class="c1">// #[macro_use]</span>
<span class="c1">// extern crate soa_derive;</span>

<span class="cp">#[derive(StructOfArray)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Cheese</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">smell</span>: <span class="kt">f64</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">color</span>: <span class="p">(</span><span class="kt">f64</span><span class="p">,</span><span class="w"> </span><span class="kt">f64</span><span class="p">,</span><span class="w"> </span><span class="kt">f64</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">with_mushrooms</span>: <span class="kt">bool</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">name</span>: <span class="nb">String</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">vec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">CheeseVec</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="194679946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194679946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194679946">(Apr 20 2020 at 14:11)</a>:</h4>
<p>Any usage code example ?</p>



<a name="194680141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194680141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194680141">(Apr 20 2020 at 14:13)</a>:</h4>
<p>Um... no, but let me check now</p>



<a name="194680562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194680562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194680562">(Apr 20 2020 at 14:16)</a>:</h4>
<p>Works for me</p>



<a name="194680583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194680583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194680583">(Apr 20 2020 at 14:16)</a>:</h4>
<blockquote>
<p>how do we handle incorrect syntax in proc macros?</p>
</blockquote>
<p><span class="user-mention" data-user-id="258149">@std::Veetaha</span>  We don't handle it in proc-macro part, we handle it in expanded <br>
macro</p>



<a name="194680950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194680950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194680950">(Apr 20 2020 at 14:19)</a>:</h4>
<p>I works for me too.</p>



<a name="194681135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681135">(Apr 20 2020 at 14:20)</a>:</h4>
<p>I mean, "works" as in "doesn't crash", but it doesn't seem to resolve the generated code</p>



<a name="194681141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681141">(Apr 20 2020 at 14:20)</a>:</h4>
<p>Okay, I'll try to debug this bit, unfortunately, there is too little info.<br>
Maybe I forgot something? I added these guys:</p>
<div class="codehilite"><pre><span></span>    &quot;rust-analyzer.procMacro.enabled&quot;: true,
    &quot;rust-analyzer.cargo.loadOutDirsFromCheck&quot;: true,
</pre></div>


<p>and ran <code>cargo build</code></p>



<a name="194681219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681219">(Apr 20 2020 at 14:21)</a>:</h4>
<p>Are you on Linux?</p>



<a name="194681222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681222">(Apr 20 2020 at 14:21)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span>  don't you see any error message  in output?</p>



<a name="194681234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681234">(Apr 20 2020 at 14:21)</a>:</h4>
<p>On linux, right</p>



<a name="194681286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681286">(Apr 20 2020 at 14:21)</a>:</h4>
<p>Nope, but I only have the server trace one, not the extension log</p>



<a name="194681384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681384">(Apr 20 2020 at 14:22)</a>:</h4>
<p>Do you have the proc macro process?</p>



<a name="194681423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681423">(Apr 20 2020 at 14:22)</a>:</h4>
<p>It shows up as <code>rust-analyzer proc-macro</code></p>



<a name="194681651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681651">(Apr 20 2020 at 14:24)</a>:</h4>
<p>By running <code>ps -a</code> I haven't found any of this</p>



<a name="194681746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681746">(Apr 20 2020 at 14:24)</a>:</h4>
<p>I wonder how we ship this server, is this a separate binary?</p>



<a name="194681959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681959">(Apr 20 2020 at 14:26)</a>:</h4>
<p>No, it's the same one, with an extra parameter</p>



<a name="194681982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194681982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194681982">(Apr 20 2020 at 14:26)</a>:</h4>
<p>No, we reuse the same binary</p>



<a name="194682044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682044">(Apr 20 2020 at 14:26)</a>:</h4>
<p>Well, put a sleep were it starts, then try to <code>strace</code> it</p>



<a name="194682138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682138">(Apr 20 2020 at 14:27)</a>:</h4>
<p>It's going to open the proc macro library, then look up a symbol inside it</p>



<a name="194682308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682308">(Apr 20 2020 at 14:28)</a>:</h4>
<p>See how it's called (e.g. <code>target/debug/deps/libsoa_derive_internal-227cd67b09461a28.so</code>) and what symbols it exports</p>



<a name="194682347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682347">(Apr 20 2020 at 14:28)</a>:</h4>
<p>Ah, never worked with <code>strace</code>)</p>



<a name="194682354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682354">(Apr 20 2020 at 14:28)</a>:</h4>
<div class="codehilite"><pre><span></span>nm -S target/debug/deps/libsoa_derive_internal-227cd67b09461a28.so | rg decl                                                                                          ✔
00000000004d73f0 0000000000000010 D __rustc_proc_macro_decls_4b07614003dcdb39fa49471d12911d65__
</pre></div>



<a name="194682419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682419">(Apr 20 2020 at 14:28)</a>:</h4>
<p><code>sudo strace -fp &lt;PID&gt;</code></p>



<a name="194682468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682468">(Apr 20 2020 at 14:29)</a>:</h4>
<p>or <code>sudo strace -e trace=open,openat -fp &lt;PID&gt;</code> to trace only <code>open()</code> calls</p>



<a name="194682645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682645">(Apr 20 2020 at 14:30)</a>:</h4>
<p>Or you could add some dbg! in <a href="https://github.com/rust-analyzer/rust-analyzer/blob/90f837829d4f2c1054751de2de695ba1c0b8ae5c/crates/ra_proc_macro/src/process.rs#L48" title="https://github.com/rust-analyzer/rust-analyzer/blob/90f837829d4f2c1054751de2de695ba1c0b8ae5c/crates/ra_proc_macro/src/process.rs#L48">https://github.com/rust-analyzer/rust-analyzer/blob/90f837829d4f2c1054751de2de695ba1c0b8ae5c/crates/ra_proc_macro/src/process.rs#L48</a></p>



<a name="194682727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682727">(Apr 20 2020 at 14:30)</a>:</h4>
<p>I just flipped this on and everything slowed to a crawl</p>



<a name="194682971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194682971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194682971">(Apr 20 2020 at 14:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216201">Edwin Cheng</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194682645" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194682645">said</a>:</p>
<blockquote>
<p>Or you could add some dbg! in <a href="https://github.com/rust-analyzer/rust-analyzer/blob/90f837829d4f2c1054751de2de695ba1c0b8ae5c/crates/ra_proc_macro/src/process.rs#L48" title="https://github.com/rust-analyzer/rust-analyzer/blob/90f837829d4f2c1054751de2de695ba1c0b8ae5c/crates/ra_proc_macro/src/process.rs#L48">https://github.com/rust-analyzer/rust-analyzer/blob/90f837829d4f2c1054751de2de695ba1c0b8ae5c/crates/ra_proc_macro/src/process.rs#L48</a></p>
</blockquote>
<p>Yeah, well, <code>strace</code> is my golden hammer.</p>



<a name="194683064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683064">(Apr 20 2020 at 14:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="203366">Jeremy Kolb</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194682727" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194682727">said</a>:</p>
<blockquote>
<p>I just flipped this on and everything slowed to a crawl</p>
</blockquote>
<p>Do you have <code>cargo check</code> disabled?</p>



<a name="194683094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683094">(Apr 20 2020 at 14:33)</a>:</h4>
<p>I wish i could use <code>strace</code> or any trace in Windows :(</p>



<a name="194683191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683191">(Apr 20 2020 at 14:33)</a>:</h4>
<p>Why not using linux?</p>



<a name="194683194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683194">(Apr 20 2020 at 14:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="203366">Jeremy Kolb</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194682727" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194682727">said</a>:</p>
<blockquote>
<p>I just flipped this on and everything slowed to a crawl</p>
</blockquote>
<p>which project?</p>



<a name="194683216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683216">(Apr 20 2020 at 14:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216201">Edwin Cheng</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194683094" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194683094">said</a>:</p>
<blockquote>
<p>I wish i could use <code>strace</code> or any trace in Windows :(</p>
</blockquote>
<p><a href="http://www.rohitab.com/apimonitor" title="http://www.rohitab.com/apimonitor">http://www.rohitab.com/apimonitor</a> (or Procmon for simpler stuff)</p>



<a name="194683333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683333">(Apr 20 2020 at 14:34)</a>:</h4>
<p>If I am using linux, who tests RA in Windows ? :)</p>



<a name="194683375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683375">(Apr 20 2020 at 14:34)</a>:</h4>
<p>I have to use Windows for my company works</p>



<a name="194683460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683460">(Apr 20 2020 at 14:35)</a>:</h4>
<p>Bruh, just install Ubuntu alongside Widows)</p>



<a name="194683471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194683471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194683471">(Apr 20 2020 at 14:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216201">Edwin Cheng</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194683333" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194683333">said</a>:</p>
<blockquote>
<p>If I am using linux, who tests RA in Windows ? :)</p>
</blockquote>
<p><span class="user-mention" data-user-id="203366">@Jeremy Kolb</span> use Windows too btw</p>



<a name="194684068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194684068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194684068">(Apr 20 2020 at 14:39)</a>:</h4>
<blockquote>
<p>If I am using linux, who tests RA in Windows ? :)</p>
</blockquote>
<p>This actually is hugely important. I am so glad that you are using windows and <span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <del>parenthesis</del> Emacs -- testing these integrations would be very hard otherwise.</p>



<a name="194686822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194686822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194686822">(Apr 20 2020 at 14:59)</a>:</h4>
<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span> is this expected that we will have more <a href="https://github.com/rust-analyzer/rust-analyzer/blob/2e0b7b0159ed922693db48f3f94ed95b1827494a/crates/ra_proc_macro/src/lib.rs#L49" title="https://github.com/rust-analyzer/rust-analyzer/blob/2e0b7b0159ed922693db48f3f94ed95b1827494a/crates/ra_proc_macro/src/lib.rs#L49"><code>ProcMacroClientKind</code>s </a> in future?</p>



<a name="194687011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194687011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194687011">(Apr 20 2020 at 15:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="258149">std::Veetaha</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194686822" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194686822">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="216201">Edwin Cheng</span> is this expected that we will have more <a href="https://github.com/rust-analyzer/rust-analyzer/blob/2e0b7b0159ed922693db48f3f94ed95b1827494a/crates/ra_proc_macro/src/lib.rs#L49" title="https://github.com/rust-analyzer/rust-analyzer/blob/2e0b7b0159ed922693db48f3f94ed95b1827494a/crates/ra_proc_macro/src/lib.rs#L49"><code>ProcMacroClientKind</code>s </a> in future?</p>
</blockquote>
<p>wasm , hopefully</p>



<a name="194688537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194688537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194688537">(Apr 20 2020 at 15:11)</a>:</h4>
<p>Yes I am on Windows and have check enabled. After restarting vscode I did notice a rogue <code>rust-analyzer</code> process lying around that I had to kill. Might be related.</p>



<a name="194690967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194690967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194690967">(Apr 20 2020 at 15:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133169">matklad</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194684068" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194684068">said</a>:</p>
<blockquote>
<blockquote>
<p>If I am using linux, who tests RA in Windows ? :)</p>
</blockquote>
<p>This actually is hugely important. I am so glad that you are using windows and <span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <del>parenthesis</del> Emacs -- testing these integrations would be very hard otherwise.</p>
</blockquote>
<p>yeah , Emacs is another important <strong>OS</strong> we have to test .</p>



<a name="194691213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194691213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194691213">(Apr 20 2020 at 15:27)</a>:</h4>
<p>I also like how <code>gnome-builder</code> was recently tried as an LSP client</p>



<a name="194694132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194694132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194694132">(Apr 20 2020 at 15:46)</a>:</h4>
<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span> is there a reason why <a href="https://github.com/rust-analyzer/rust-analyzer/blob/2e0b7b0159ed922693db48f3f94ed95b1827494a/crates/ra_proc_macro_srv/src/dylib.rs#L190" title="https://github.com/rust-analyzer/rust-analyzer/blob/2e0b7b0159ed922693db48f3f94ed95b1827494a/crates/ra_proc_macro_srv/src/dylib.rs#L190"><code>list_macros</code> returns a <code>Result</code></a>? I don't see any fallable operation in it</p>



<a name="194694474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194694474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194694474">(Apr 20 2020 at 15:48)</a>:</h4>
<p>Yes, it should return the list directly.</p>



<a name="194712580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194712580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194712580">(Apr 20 2020 at 18:11)</a>:</h4>
<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span> , what about merging the <a href="https://github.com/rust-analyzer/rust-analyzer/blob/cd6d788c159240e3910b5df92b641f93d1cf79a5/crates/ra_proc_macro/src/process.rs#L20-L29" title="https://github.com/rust-analyzer/rust-analyzer/blob/cd6d788c159240e3910b5df92b641f93d1cf79a5/crates/ra_proc_macro/src/process.rs#L20-L29"><code>ProcMacroProcessThread</code></a> with <code>ProcMacroProcessSrv</code>? This way we also get rid of the weak pointer. As I can tell for now this struct has no logic apart from holding the <code>jod_thread</code></p>



<a name="194713327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194713327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194713327">(Apr 20 2020 at 18:17)</a>:</h4>
<p>Um.. sound reasonable. I really forget why I design the structure like this.</p>



<a name="194713540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194713540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194713540">(Apr 20 2020 at 18:19)</a>:</h4>
<p>Yeah, there is probably something caveat-y underneath...</p>



<a name="194713983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194713983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194713983">(Apr 20 2020 at 18:22)</a>:</h4>
<p>Ah</p>



<a name="194714265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194714265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194714265">(Apr 20 2020 at 18:25)</a>:</h4>
<p>I remember now, it is because we hold an arc pointer for each proc-macro and we might destroyed the thread but proc-macro itself still held by crates. We use the weak pointer to separate that thread and proc-macros</p>



<a name="194714480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194714480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194714480">(Apr 20 2020 at 18:27)</a>:</h4>
<p>This ownership story is quite complicated. I wonder if we can avoid it.</p>



<a name="194726674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194726674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194726674">(Apr 20 2020 at 20:14)</a>:</h4>
<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span> shouldn't we pass the same arguments to the proc macro process in <a href="https://github.com/rust-analyzer/rust-analyzer/blob/cd6d788c159240e3910b5df92b641f93d1cf79a5/crates/ra_proc_macro/src/process.rs#L48-L71" title="https://github.com/rust-analyzer/rust-analyzer/blob/cd6d788c159240e3910b5df92b641f93d1cf79a5/crates/ra_proc_macro/src/process.rs#L48-L71"><code>fn restart()</code> as we do in <code>fn run()</code></a>?</p>



<a name="194726838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194726838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194726838">(Apr 20 2020 at 20:15)</a>:</h4>
<p>Yeah, it is a bug , nice catch !</p>



<a name="194728534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194728534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194728534">(Apr 20 2020 at 20:29)</a>:</h4>
<p>I will submit a PR after <a href="https://github.com/rust-analyzer/rust-analyzer/pull/4061" title="https://github.com/rust-analyzer/rust-analyzer/pull/4061">https://github.com/rust-analyzer/rust-analyzer/pull/4061</a> is merged.</p>



<a name="194730264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194730264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194730264">(Apr 20 2020 at 20:42)</a>:</h4>
<p>I also wonder if there is any data race possible. Like can't RA send several requests to proc marco srv in parallel? LSP (or JSON RPC in general, not sure) uses request ids for example...</p>



<a name="194730396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194730396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194730396">(Apr 20 2020 at 20:43)</a>:</h4>
<p>The send request is blocking from client to server.</p>



<a name="194730553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194730553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194730553">(Apr 20 2020 at 20:44)</a>:</h4>
<p>Yeah, it's blocking, but can't RA <code>send_task()</code> in parallel threads such that both threads are blocked, but then some of them randomly can get the response it was not awaiting for.</p>



<a name="194730818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194730818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194730818">(Apr 20 2020 at 20:46)</a>:</h4>
<p>Here is my imaginary workflow:</p>
<ol>
<li>RA thead <code>foo</code> sends request <code>1</code> and waits for the response.</li>
<li>Proc macro srv is blocked processing this request.</li>
<li>RA thread <code>bar</code> send request <code>2</code> and waits for the response.</li>
<li>Proc macro srv writes response for request <code>1</code> to <code>stdout</code>.</li>
<li>RA thread <code>bar</code> reads the stdout with the response for request <code>1</code> (BUG)</li>
</ol>



<a name="194731259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194731259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194731259">(Apr 20 2020 at 20:49)</a>:</h4>
<p>Note that we send the <code>task_sender</code> channel into the thread channel,  the thread use that channel to send back the response.</p>



<a name="194731492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194731492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194731492">(Apr 20 2020 at 20:51)</a>:</h4>
<p>And we only have a single worker thread in client side.</p>



<a name="194731709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194731709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194731709">(Apr 20 2020 at 20:52)</a>:</h4>
<p>Oh, right, now I see...</p>



<a name="194737797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194737797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194737797">(Apr 20 2020 at 21:47)</a>:</h4>
<p>Hmh, I think we (me) broke something, now one core is constantly 100% and no hints in the edittor appear....</p>



<a name="194737808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194737808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194737808">(Apr 20 2020 at 21:47)</a>:</h4>
<p><a href="/user_uploads/4715/XvvxqQQyFb0d-IqMve4SxGgM/image.png" title="image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/XvvxqQQyFb0d-IqMve4SxGgM/image.png" title="image.png"><img src="/user_uploads/4715/XvvxqQQyFb0d-IqMve4SxGgM/image.png"></a></div>



<a name="194737933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194737933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194737933">(Apr 20 2020 at 21:49)</a>:</h4>
<p>Okay it just took some time and everything stabilized..</p>



<a name="194738048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194738048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194738048">(Apr 20 2020 at 21:50)</a>:</h4>
<p>Don't know how, but now I don't get that "Empty response error"</p>



<a name="194762490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194762490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194762490">(Apr 21 2020 at 05:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216201">Edwin Cheng</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194731492" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194731492">said</a>:</p>
<blockquote>
<p>And we only have a single worker thread in client side.</p>
</blockquote>
<p>Wouldn't it be worth being able to support multiple concurrent expansions?  I know it came from <a href="https://github.com/rust-analyzer/rust-analyzer/pull/3738#discussion_r399637997" title="https://github.com/rust-analyzer/rust-analyzer/pull/3738#discussion_r399637997">https://github.com/rust-analyzer/rust-analyzer/pull/3738#discussion_r399637997</a>.</p>



<a name="194762825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194762825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194762825">(Apr 21 2020 at 05:46)</a>:</h4>
<p>iirc, currently RA  are concurrent but not parallel, which means if there are multiple requests from lsp client, <strong>AND</strong> they changed salsa db, RA will cancel former request. I think single worker thread in proc-macro client fit this design. But of course I only have vague understanding in this part.</p>



<a name="194762915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194762915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194762915">(Apr 21 2020 at 05:48)</a>:</h4>
<p>And note that if everything implemented correctly, a request to proc-macro expansion must be triggered by a new salsa db invocation, which must change the db itself.</p>



<a name="194762920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194762920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194762920">(Apr 21 2020 at 05:48)</a>:</h4>
<p>But a single LSP request (e.g. type hints) might expand multiple proc macros anyway</p>



<a name="194762984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194762984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194762984">(Apr 21 2020 at 05:50)</a>:</h4>
<p>Yes, but these requests must be synchronized  in current design.</p>



<a name="194763315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194763315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194763315">(Apr 21 2020 at 05:58)</a>:</h4>
<p>Got it, thanks</p>



<a name="194763617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194763617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194763617">(Apr 21 2020 at 06:05)</a>:</h4>
<p>But there is a rare case here: two concurrent request is asking for expansion at the same time (the salsa db is not modified yet),  that is the potential  bug mentioned. But as I answered previously, we pass a sender channel to the worker thread for replying to prevent this bug.</p>



<a name="194765770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194765770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194765770">(Apr 21 2020 at 06:46)</a>:</h4>
<p>Well, I was looking at it as a potential optimization, not a bug <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="194953373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/194953373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#194953373">(Apr 22 2020 at 16:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="258149">std::Veetaha</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194679945" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/194679945">said</a>:</p>
<blockquote>
<p>The code:</p>
<div class="codehilite"><pre><span></span><span class="k">use</span><span class="w"> </span><span class="n">soa_derive</span>::<span class="n">StructOfArray</span><span class="p">;</span><span class="w"></span>

<span class="c1">// #[macro_use]</span>
<span class="c1">// extern crate soa_derive;</span>

<span class="cp">#[derive(StructOfArray)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Cheese</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">smell</span>: <span class="kt">f64</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">color</span>: <span class="p">(</span><span class="kt">f64</span><span class="p">,</span><span class="w"> </span><span class="kt">f64</span><span class="p">,</span><span class="w"> </span><span class="kt">f64</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">with_mushrooms</span>: <span class="kt">bool</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">name</span>: <span class="nb">String</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">vec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">CheeseVec</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


</blockquote>
<p>Huh. I'm pretty sure it wasn't working at the time, but now I even get completions in spite of <a href="https://github.com/rust-analyzer/rust-analyzer/pull/4029" title="https://github.com/rust-analyzer/rust-analyzer/pull/4029">https://github.com/rust-analyzer/rust-analyzer/pull/4029</a>:</p>
<p><a href="/user_uploads/4715/OA-3xNU5t6KWXpEqZxpxpjQ0/image.png" title="image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/OA-3xNU5t6KWXpEqZxpxpjQ0/image.png" title="image.png"><img src="/user_uploads/4715/OA-3xNU5t6KWXpEqZxpxpjQ0/image.png"></a></div>



<a name="195000993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195000993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195000993">(Apr 22 2020 at 22:53)</a>:</h4>
<p>Really the performance of proc_macro_srv is not very impressive, I wish we could paralellize it...</p>



<a name="195102586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195102586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195102586">(Apr 23 2020 at 18:42)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> I just found out why sometimes the proc-macro srv will be deadlocked. It is because we load and unload dlls for each request. However, currently rustc TLS is <a href="https://github.com/rust-lang/rust/blob/413a12909f3b149af17d75268ed4a136afb82c36/src/libstd/sys_common/thread_local.rs#L230" title="https://github.com/rust-lang/rust/blob/413a12909f3b149af17d75268ed4a136afb82c36/src/libstd/sys_common/thread_local.rs#L230">leaky</a> , such that if we do it a lot of time, all TLS index will be consumed and it will be deadlocked inside panic (it is because panic itself is using TLS too).</p>



<a name="195102810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195102810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195102810">(Apr 23 2020 at 18:44)</a>:</h4>
<p>The maxium number of TLS in Windows are small (<a href="https://docs.microsoft.com/en-us/windows/win32/procthread/thread-local-storage?redirectedfrom=MSDN" title="https://docs.microsoft.com/en-us/windows/win32/procthread/thread-local-storage?redirectedfrom=MSDN">1,088</a>), so basically it will be hit for sure..</p>



<a name="195103188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195103188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195103188">(Apr 23 2020 at 18:47)</a>:</h4>
<p>A simplest solution is we spawn a thread for each request and join it. Another solution will be we cached all dlls ..</p>



<a name="195105326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195105326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195105326">(Apr 23 2020 at 19:02)</a>:</h4>
<p>I !<span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span> TLS</p>



<a name="195105421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195105421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195105421">(Apr 23 2020 at 19:03)</a>:</h4>
<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span> why do we need to unload dlls? I'd expect to keep all proc macros in memory all the time</p>



<a name="195105438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195105438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195105438">(Apr 23 2020 at 19:03)</a>:</h4>
<p>(but it probably make sense to lazy-load them)</p>



<a name="195105635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195105635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195105635">(Apr 23 2020 at 19:05)</a>:</h4>
<p>My initial thought was saving memory for the dll, but it seems to be not a good idea now :)</p>



<a name="195113268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195113268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195113268">(Apr 23 2020 at 20:10)</a>:</h4>
<p>On macOS you are not supposed to unload dylibs. In fact I believe you have to call dlclose twice to actually unload it. Otherwise it will be kept open and reused the next time you use dlopen. Even if the dylib has changed since.</p>



<a name="195124028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195124028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pksunkara <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195124028">(Apr 23 2020 at 21:52)</a>:</h4>
<p>Can someone tell me why <code>proc_macro</code> support needs<code> loadOutDirsFromCheck</code> option enabled? I might be a noob for asking this but why are out dirs even checked for? Is it not always target?</p>



<a name="195138208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195138208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195138208">(Apr 24 2020 at 01:20)</a>:</h4>
<p><span class="user-mention" data-user-id="254853">@pksunkara</span> Although it is always target, but we dont't know the full path. Additionally, e.g. if using <code>sccache</code>, it might be not in <code>target</code>...</p>



<a name="195286424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195286424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195286424">(Apr 25 2020 at 14:07)</a>:</h4>
<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span>, smol question. Am I right that we use a separate process for proc macro expanding to prevent crashing the rust-analyzer process if something really bad happens inside of a proc macro, and are there any other raesons?</p>



<a name="195286472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195286472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195286472">(Apr 25 2020 at 14:08)</a>:</h4>
<p>That's the main reason. I think</p>



<a name="195287524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195287524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195287524">(Apr 25 2020 at 14:39)</a>:</h4>
<p><span class="user-mention" data-user-id="216201">@Edwin Cheng</span> I am getting this error with today's nightly, did you see it before?</p>
<div class="codehilite"><pre><span></span>thread &#39;main&#39; panicked at &#39;Cannot create expander for /home/veetaha/dev/rust-analyzer/target/debug/deps/libserde_repr-33c31e7306fd2bdf.so: &quot;Dynamic loading not supported&quot;&#39;, crates/ra_proc_macro_srv/src/lib.rs:45:31
</pre></div>



<a name="195287683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195287683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195287683">(Apr 25 2020 at 14:43)</a>:</h4>
<p>No.. oh ... um...</p>



<a name="195287689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195287689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195287689">(Apr 25 2020 at 14:43)</a>:</h4>
<p>Do we compile our nightly binary with musl?</p>



<a name="195287779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195287779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195287779">(Apr 25 2020 at 14:45)</a>:</h4>
<p><a href="https://git.musl-libc.org/cgit/musl/tree/src/ldso/dlopen.c" title="https://git.musl-libc.org/cgit/musl/tree/src/ldso/dlopen.c">https://git.musl-libc.org/cgit/musl/tree/src/ldso/dlopen.c</a></p>



<a name="195287810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195287810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195287810">(Apr 25 2020 at 14:46)</a>:</h4>
<p>FXXXXK</p>



<a name="195287899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195287899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195287899">(Apr 25 2020 at 14:49)</a>:</h4>
<blockquote>
<p>FXXXXK</p>
</blockquote>
<p>Not sure what this means )<br>
Hmm, this is very strange that musl doesn't support dlopen loading...</p>



<a name="195287979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195287979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195287979">(Apr 25 2020 at 14:51)</a>:</h4>
<p>I guess we do <a href="https://github.com/rust-analyzer/rust-analyzer/blob/fc57358efda7c028cbe8a438446cce5f540f48ca/.github/workflows/release.yaml#L42" title="https://github.com/rust-analyzer/rust-analyzer/blob/fc57358efda7c028cbe8a438446cce5f540f48ca/.github/workflows/release.yaml#L42">compile it with musl</a><br>
I also wonder why this was not appearing before, something has changed...</p>



<a name="195288039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195288039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195288039">(Apr 25 2020 at 14:52)</a>:</h4>
<p>Just some dirty words to express my angry of the mess of handling platform depends dlls and tls related stuffs.</p>



<a name="195288049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195288049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195288049">(Apr 25 2020 at 14:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="258149">std::Veetaha</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/195287979" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/195287979">said</a>:</p>
<blockquote>
<p>I guess we do <a href="https://github.com/rust-analyzer/rust-analyzer/blob/fc57358efda7c028cbe8a438446cce5f540f48ca/.github/workflows/release.yaml#L42" title="https://github.com/rust-analyzer/rust-analyzer/blob/fc57358efda7c028cbe8a438446cce5f540f48ca/.github/workflows/release.yaml#L42">compile it with musl</a><br>
I also wonder why this was not appearing before, something has changed...</p>
</blockquote>
<p>We don't run test with the nightly build, I think .</p>



<a name="195289698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195289698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195289698">(Apr 25 2020 at 15:33)</a>:</h4>
<p>Wait, so are proc macros working for anyone using the marketplace release?</p>



<a name="195327036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195327036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195327036">(Apr 26 2020 at 09:48)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> I don't think it is working except Windows users</p>



<a name="195328781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195328781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195328781">(Apr 26 2020 at 10:38)</a>:</h4>
<p>Should we build the binaries on <code>glibc</code>?</p>



<a name="195329151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195329151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195329151">(Apr 26 2020 at 10:51)</a>:</h4>
<p>I wonder how can the toolchain work on an alpine host. But it does.</p>



<a name="195329225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195329225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195329225">(Apr 26 2020 at 10:53)</a>:</h4>
<p>If building for <code>glibc</code>, please build using an old system, otherwise I can't run them on my debian system, as you can't run an executable compiled for  newer version of <code>glibc</code> on an older system.</p>



<a name="195329393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195329393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195329393">(Apr 26 2020 at 10:59)</a>:</h4>
<p>GitHub Actions seems to support Ubuntu 16.04. Is that old enough? But yeah, binary compatibility across distros is a mess.</p>



<a name="195329759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195329759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195329759">(Apr 26 2020 at 11:11)</a>:</h4>
<p>Does it matter at all against which glibc we are building? We don’t use C<br>
code, so I think only the version of glibc used to build rust standard<br>
library matters?</p>
<p>Hm, actually, I think I am missing some large piece of knowledge here...<br>
Why build-time version of glibc matters at all? Like, what matters is the<br>
header files(because we link glibc dynamically), and I assume Rust just has<br>
some extern C declarations which are fixed?</p>



<a name="195330930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195330930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195330930">(Apr 26 2020 at 11:42)</a>:</h4>
<p>You might have a point there. My <code>rust-analyzer</code> binary (built on Arch with <code>glibc 2.31</code> appears to work on Ubuntu 14.04 (with <code>glibc 2.19</code>).</p>



<a name="195331099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195331099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195331099">(Apr 26 2020 at 11:47)</a>:</h4>
<p>Since Sundays is usually "merge day", let me file a PR to switch to <code>x86_64-unknown-linux-gnu</code> to have something exciting in the next release <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span>. Maybe we could even include <a href="https://github.com/rust-analyzer/rust-analyzer/pull/4153" title="https://github.com/rust-analyzer/rust-analyzer/pull/4153">https://github.com/rust-analyzer/rust-analyzer/pull/4153</a></p>



<a name="195331495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195331495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195331495">(Apr 26 2020 at 11:58)</a>:</h4>
<p>I am prepping a big "relase" post on monday, so I'll fold this into the <em>next</em> release, and not this one :)</p>



<a name="195599232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195599232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195599232">(Apr 28 2020 at 17:32)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> I realize you're busy, but what do you say about merging <a href="https://github.com/rust-analyzer/rust-analyzer/pull/4157" title="https://github.com/rust-analyzer/rust-analyzer/pull/4157">https://github.com/rust-analyzer/rust-analyzer/pull/4157</a> soon-ish to have it bake before Monday? It also resolves <a href="https://github.com/rust-analyzer/rust-analyzer/pull/4143" title="https://github.com/rust-analyzer/rust-analyzer/pull/4143">https://github.com/rust-analyzer/rust-analyzer/pull/4143</a>, but on the other hand it breaks bors on every open PR <span aria-label="sad" class="emoji emoji-2639" role="img" title="sad">:sad:</span>.</p>



<a name="195615479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195615479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195615479">(Apr 28 2020 at 19:41)</a>:</h4>
<p>that's a fun thread: <a href="https://users.rust-lang.org/t/loading-dynamic-libraries-from-memory/41697" title="https://users.rust-lang.org/t/loading-dynamic-libraries-from-memory/41697">https://users.rust-lang.org/t/loading-dynamic-libraries-from-memory/41697</a></p>



<a name="195664005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195664005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195664005">(Apr 29 2020 at 06:00)</a>:</h4>
<p>Nice, I hope someone will publish a crate for that &lt;3. </p>
<p>And here are some other fun and (non practical) solutions (projects): </p>
<ul>
<li>Embedding an x86 VM and binding all allowed syscalls.</li>
<li>Passing some magic RUSC_FLAGS to <code>cargo check</code> to make it generating LLVM IR for the proc-macro dll , and embedding a LLVM jit interpreter to run that.</li>
</ul>



<a name="195664550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195664550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195664550">(Apr 29 2020 at 06:08)</a>:</h4>
<p>Is anyone using nightly instead of source builds on Linux? I wonder if they still work.</p>



<a name="195664576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195664576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195664576">(Apr 29 2020 at 06:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216201">Edwin Cheng</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/195664005" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/proc-macro/near/195664005">said</a>:</p>
<blockquote>
<ul>
<li>Pass some magic RUSC_FLAGS to <code>cargo check</code> to make it general LLVM IR for the proc-macro dll , and embedding a LLVM jit interpreter to run that.</li>
</ul>
</blockquote>
<p>Well, there's <code>miri</code>...</p>



<a name="195665161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/proc-macro/near/195665161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/proc-macro.html#195665161">(Apr 29 2020 at 06:21)</a>:</h4>
<p>x86towasm sounds like a name of a project which should exist :D</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>